package com.ciaojian.core.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ciaojian.core.enums.business.WorkerWorkerStatusEnum;
import com.ciaojian.core.mapper.WorkerMapper;
import com.ciaojian.core.model.Worker;
import com.ciaojian.core.model.vo.OrderSkipVo;
import com.ciaojian.core.util.Result;

import java.util.List;


/**
 * @author Atlakyn
 */
public abstract class WorkerService<M extends BaseMapper<T>, T> extends ServiceImpl<WorkerMapper, Worker> {
    /**
     * 查询门店下的发型师
     *
     * @param storeId 门店ID
     * @return 发型师列表
     */
    public List<Worker> listByStoreId(Integer storeId) {
        return this.lambdaQuery()
                .eq(Worker::getStoreId, storeId)
                .ne(Worker::getStatus, 8)
                .list();
    }

    /**
     * 根据 id 查询发型师名称
     *
     * @param id 发型师id
     * @return 发型师名称
     */
    public String getWorkerNameById(Integer id) {
        return baseMapper.getWorkerNameById(id);
    }


    /**
     * 修改发型师工作状态
     *
     * @param workerId     发型师ID
     * @param workerStatus 发型师工作状态
     * @return 修改结果
     */
    public boolean updateWorkerStatus(Integer workerId, WorkerWorkerStatusEnum workerStatus) {
        return lambdaUpdate()
                .set(Worker::getWorkerStatus, workerStatus)
                .eq(Worker::getId, workerId)
                .update();
    }

}
